
import './Game.css';

export enum GridChar {
    empty = 0,
    charA = 1,
    charB = 2
}

interface GridProps {
    char: GridChar
    idx?:number
    onClick?:(idx:number)=>void
}

const Grid: React.FC<GridProps> = ({ char,idx,onClick }) => {
    var charTab = ["","X","O"]
    var charStr = charTab[char]
    
    function handleClick() {
        onClick&&onClick(idx??0)
    }

    return <button className="grid"  style={{ color: char==GridChar.charA?"#C1FFC1":"#FFC1C1" }} onClick={handleClick}>
        {charStr}</button>
}


export default Grid;